/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Malt")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Malt.findAll", query = "SELECT m FROM Malt m ORDER BY m.maltName ASC"),
    @NamedQuery(name = "Malt.findByMaltID", query = "SELECT m FROM Malt m WHERE m.maltID = :maltID"),
    @NamedQuery(name = "Malt.findByMaltName", query = "SELECT m FROM Malt m WHERE m.maltName = :maltName"),
    @NamedQuery(name = "Malt.findByMaltColor", query = "SELECT m FROM Malt m WHERE m.maltColor = :maltColor"),
    @NamedQuery(name = "Malt.findByMaltSG", query = "SELECT m FROM Malt m WHERE m.maltSG = :maltSG"),
    @NamedQuery(name = "Malt.findByMaltEff", query = "SELECT m FROM Malt m WHERE m.maltEff = :maltEff"),
    @NamedQuery(name = "Malt.findByMaltBagLbs", query = "SELECT m FROM Malt m WHERE m.maltBagLbs = :maltBagLbs"),
    @NamedQuery(name = "Malt.findByMaltOnHand", query = "SELECT m FROM Malt m WHERE m.maltOnHand = :maltOnHand"),
    @NamedQuery(name = "Malt.findByMaltSpoken", query = "SELECT m FROM Malt m WHERE m.maltSpoken = :maltSpoken"),
    @NamedQuery(name = "Malt.findByMaltOnOrder", query = "SELECT m FROM Malt m WHERE m.maltOnOrder = :maltOnOrder"),
    @NamedQuery(name = "Malt.findByMaltMinimum", query = "SELECT m FROM Malt m WHERE m.maltMinimum = :maltMinimum"),
    @NamedQuery(name = "Malt.findByMaltCost", query = "SELECT m FROM Malt m WHERE m.maltCost = :maltCost")})
public class Malt implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "MaltID")
    private Integer maltID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 60)
    @Column(name = "MaltName")
    private String maltName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltColor")
    private float maltColor;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltSG")
    private int maltSG;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltEff")
    private int maltEff;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltBagLbs")
    private int maltBagLbs;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltOnHand")
    private float maltOnHand;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltSpoken")
    private float maltSpoken;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltOnOrder")
    private float maltOnOrder;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaltMinimum")
    private float maltMinimum;
    @Basic(optional = false)
    @NotNull
    @Column(name = "maltCost")
    private float maltCost;
    @OneToOne
    @JoinTable(
        name="JTMaltToStock",
        joinColumns={ @JoinColumn(name="MaltID", referencedColumnName="MaltID", unique=true)},
        inverseJoinColumns={ @JoinColumn(name="StockID", referencedColumnName="StockID", unique=true)}
    )
    private StockCode stockCode;
    @OneToMany(mappedBy = "maltID")
    private Collection<MaltBill> maltBillCollection;
    @OneToMany(mappedBy = "maltID")
    private Collection<MaltNotes> maltNoteCollection;

    public Malt() {
    }

    public Malt(Integer maltID) {
        this.maltID = maltID;
    }

    public Malt(Integer maltID, String maltName, float maltColor, int maltSG, int maltEff, int maltBagLbs, float maltOnHand, float maltSpoken, float maltOnOrder, float maltMinimum, float maltCost) {
        this.maltID = maltID;
        this.maltName = maltName;
        this.maltColor = maltColor;
        this.maltSG = maltSG;
        this.maltEff = maltEff;
        this.maltBagLbs = maltBagLbs;
        this.maltOnHand = maltOnHand;
        this.maltSpoken = maltSpoken;
        this.maltOnOrder = maltOnOrder;
        this.maltMinimum = maltMinimum;
        this.maltCost = maltCost;
    }

    public Integer getMaltID() {
        return maltID;
    }

    public void setMaltID(Integer maltID) {
        this.maltID = maltID;
    }

    public String getMaltName() {
        return maltName;
    }

    public void setMaltName(String maltName) {
        this.maltName = maltName;
    }

    public float getMaltColor() {
        return maltColor;
    }

    public void setMaltColor(float maltColor) {
        this.maltColor = maltColor;
    }

    public int getMaltSG() {
        return maltSG;
    }

    public void setMaltSG(int maltSG) {
        this.maltSG = maltSG;
    }

    public int getMaltEff() {
        return maltEff;
    }

    public void setMaltEff(int maltEff) {
        this.maltEff = maltEff;
    }

    public int getMaltBagLbs() {
        return maltBagLbs;
    }

    public void setMaltBagLbs(int maltBagLbs) {
        this.maltBagLbs = maltBagLbs;
    }

    public float getMaltOnHand() {
        return maltOnHand;
    }

    public void setMaltOnHand(float maltOnHand) {
        this.maltOnHand = maltOnHand;
    }

    public float getMaltSpoken() {
        return maltSpoken;
    }

    public void setMaltSpoken(float maltSpoken) {
        this.maltSpoken = maltSpoken;
    }

    public float getMaltOnOrder() {
        return maltOnOrder;
    }

    public void setMaltOnOrder(float maltOnOrder) {
        this.maltOnOrder = maltOnOrder;
    }

    public float getMaltMinimum() {
        return maltMinimum;
    }

    public void setMaltMinimum(float maltMinimum) {
        this.maltMinimum = maltMinimum;
    }

    public float getMaltCost() {
        return maltCost;
    }

    public void setMaltCost(float maltCost) {
        this.maltCost = maltCost;
    }

    public StockCode getStockCode() {
        return stockCode;
    }

    public void setStockCode(StockCode stockCode) {
        this.stockCode = stockCode;
    }

    @XmlTransient
    public Collection<MaltBill> getMaltBillCollection() {
        return maltBillCollection;
    }

    public void setMaltBillCollection(Collection<MaltBill> maltBillCollection) {
        this.maltBillCollection = maltBillCollection;
    }

    @XmlTransient
    public Collection<MaltNotes> getMaltNoteCollection() {
        return maltNoteCollection;
    }

    public void setMaltNoteCollection(Collection<MaltNotes> maltNoteCollection) {
        this.maltNoteCollection = maltNoteCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (maltID != null ? maltID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Malt)) {
            return false;
        }
        Malt other = (Malt) object;
        if ((this.maltID == null && other.maltID != null) || (this.maltID != null && !this.maltID.equals(other.maltID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Malt[ maltID=" + maltID + " ]";
    }
    
}
